/*
 * Copyright (c) 2006-2017, Yunnan Sanjiu Network technology Co., Ltd.
 * 
 * All rights reserved.
 */
package com.niguang.labour.common.config.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.niguang.labour.common.util.MoneyUtil;

import java.io.IOException;

/**
 * @author Administrator on 2017/6/29.
 */
public class Double2StringSerializer extends JsonSerializer<Double> {

    public static final Double2StringSerializer instance = new Double2StringSerializer();

    @Override
    public void serialize(Double aDouble, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
            throws IOException {
        String doubleStr = MoneyUtil.formatMoney2Decimal(aDouble + "");
        jsonGenerator.writeString(doubleStr + "");
    }
}
